<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=1000, initial-scale=1.0, maximum-scale=1.0">
	    <!-- Loading Bootstrap -->
	    <link href="Public/Admin/Flat/dist/css/vendor/bootstrap.min.css" rel="stylesheet">
	    <!-- Loading Flat UI -->
	    <link href="Public/Admin/Flat/dist/css/flat-ui.css" rel="stylesheet">
	    <link rel="shortcut icon" href="Public/Admin/Flat/img/favicon.ico">
    	<script src="Public/js/jquery-1.7.2.min.js"></script>
	    
	    <script type="text/javascript">
	    	$(function(){
	    		$('.edit').click(function(){
	    			var n = $(this).index('.edit');
	    			$('.sho').eq(n).attr({style:'display:none'});	 
	    			$('.hid').eq(n).removeAttr("style");
	    		})
	    		$('.jqdel').click(function(){
	    			var n = $(this).index('.jqdel');
	    			$('.sho').eq(n).removeAttr("style");	 
	    			$('.hid').eq(n).attr({style:'display:none'});
	    		})
	    	})
	    </script>
	</head>
		<table class="table table-hover">
			<tr class="active">
			  <th width="80">ID</th>
			  <?php foreach ($typeattrdata as $v){?>
			  <th><?php echo $v['taname']?></th>
			  <?php }?>
			  <th width="70">库存</th>
			  <th width="90">货号</th>
			  <th width="250">操作</th>
			</tr>
			<?php foreach ($goodslistdata as $v){?>
			<tr class="sho">
				<td><?php echo $v['glid']?></td>
				<?php $glattrid =  explode(',',$v['glattrid']) ?>
				<?php foreach ($glattrid as $v1){?>
					<td><?php echo $v1?></td>
				<?php }?>
				<td><?php echo $v['glinv']?></td>
				<td><?php echo $v['glnum']?></td>
				<td>
					<button glid="<?php echo $v['glid']?>" class="edit btn btn-xs btn-primary">编辑</button>
					<a href="<?php echo U('del',array('glid'=>$v['glid'],'id'=>$v['goods_gid']))?>" class="btn btn-xs btn-warning">删除</a>
				</td>
			</tr>
			<!--隐藏-->
		<form action="" method="post">
			<input type="hidden" name="goods_gid" value="<?php echo $goodsattrdata[0]['goods_gid']?>"/>
			<tr class="hid" style="display: none;">
				 <td><?php echo $v['glid']?></td>
				  <?php foreach ($goodsattrdata as $kk=>$v2){?>
						<td class="sel" attr="<?php echo $v['glid'].$kk?>">
							<select  name="glattrid[]">
								<?php $gavalue = explode(',',$v2['gavalue']) ?>
								<?php foreach ($gavalue as $v3){?>
									<option <?php foreach ($userattr[$v['glid']] as $v4) { ?> <?php if($v3==$v4){?>
                selected="selected" 
               <?php }?><?php } ?>value="<?php echo $v3?>"><?php echo $v3?></option> 
								<?php }?>
							</select>
						</td>
				  <?php }?>
				  <td width="70"><input style="width: 70px;" value="<?php echo $v['glinv']?>" type="text" name="glinv" id="" /></td>
				  <td width="90"><input style="width: 90px;" value="<?php echo $v['glnum']?>" type="text" name="glnum" id="" /></td>
				  <td width="250">
				  	<button class="btn btn-xs btn-primary jqsub" type="submit"> 确认修改 </button>
				  	<button class="btn btn-xs btn-default jqdel" type=""> 取消 </button>
				  </td>
				</tr>
			</form>
			<?php }?>
			<!--<?php echo p($typeattrdata)?><?php echo p($goodslistdata)?><?php echo p($goodsattrdata)?><?php echo p($userattr)?>-->
			<!--添加-->
			<form action="" method="post">
				<input type="hidden" name="goods_gid" value="<?php echo $goodsattrdata[0]['goods_gid']?>"/>
				<tr class="active">
				  <td width="80">添加</td>
				  <?php foreach ($goodsattrdata as $v){?>
						<td>
							<select name="glattrid[]">
								<?php $gavalue = explode(',',$v['gavalue']) ?>
								<?php foreach ($gavalue as $v1){?>
									<option value="<?php echo $v1?>"><?php echo $v1?></option>
								<?php }?>
							</select>
						</td>
				  <?php }?>
				  <td width="70"><input style="width: 70px;" type="text" name="glinv" id="" /></td>
				  <td width="90"><input style="width: 90px;" type="text" name="glnum" id="" /></td>
				  <td width="250">

				  	<button class="btn btn-xs btn-primary " type="submit"> 确认添加 </button>
				  </td>
				</tr>
			</form>
		</table>
		
		
		
		
		
		
		
	</body>
</html>
